package dome5Steam;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Teacher implements Comparable<Teacher> {
    public String name;
    public int age;
    public double score;

    @Override
    public String toString() {
        return "Teacher{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}'+"\n";
    }

    @Override
    public int compareTo(Teacher o) {
        //按照年龄实现升序
//        if (this.age > o.age) {
//            return 1;
//        } else if (this.age < o.age) {
//            return -1;
//        }
//        return 0;
        return this.age - o.age;
    }
}